Sets the tile CLASS (TILE_PASS/TILE_SOLID/TILE_LOW_COVER) at (x, y) in the current room’s collision tile layer, leaving every project-defined flag bit untouched - the setter twin of tile_class. What most destructible-terrain/dig/unlock code wants: "this cell no longer blocks" is tile_set_class(x, y, TILE_PASS).
Works differently on Game Boy - The game keeps at most 16 changed squares of a room at once (32 with tile_set_index, 48 with autotiles) until the player leaves; a change that finds no free place does nothing, and nothing tells you.
Works differently on Game Boy Color - The game keeps at most 16 changed squares of a room at once (32 with tile_set_index, 48 with autotiles) until the player leaves; a change that finds no free place does nothing, and nothing tells you.
On other consoles this differs: see Side by side and How the consoles differ.
tile_set_class(x, y, cls)| Name | Type |
|---|---|
x | real |
y | real |
cls | tile_kind |
Nothing.
Sets the tile class (TILE_PASS, TILE_SOLID or TILE_LOW_COVER) at (x, y) in the current room's collision tile layer, leaving every project-defined flag bit untouched - the setter twin of tile_class. This is what most destructible-terrain, digging or unlocking code wants: "this cell no longer blocks" is tile_set_class(x, y, TILE_PASS). A door that becomes passable when unlocked, a bridge that becomes solid once lowered, and a wall knocked down by an explosion are all the same one-line call, just with a different class in each direction and a different condition triggering it.
x and y are a place in the room, counted from the room's top-left corner. That is also where the tile grid starts, so the very first tile covers x from 0 to 7 and y from 0 to 7 (tiles are 8 by 8 pixels).
Collision only - this never changes what is drawn. Set a wall's class to TILE_PASS and it still looks like a wall; nothing about the tile's own graphics changed, only whether it blocks movement. A project that wants the room to look different too has three independent options, and picking the right one matters: tile_set_index repaints exactly this one cell to a different tile from the same tileset - the direct pairing for a permanent dig/destructible-terrain mechanic, and the one to reach for first; an instance placed on top of the now-passable cell (a rubble sprite, an open-door sprite) works for anything that needs its own independent lifetime (something that can later be removed, animated on its own, or collided with separately); and, if the tileset already declares an animated group over that same tile, tile_anim_frame swaps its art at the same moment the class changes, but only for every cell sharing that tile's hardware index at once - see tile_set_index's own docs for exactly how it differs from tile_anim_frame. All three are independent of this call and of each other; none of them does another's job.
A no-op if the current room has no collision tile layer, if (x, y) falls outside it, or if that layer is too large for this engine's live-mutable budget (tile_flags would then still read the room's original, unchanged data).
Changes are not saved and do not persist across a room change or a save/load - a room's tile layer resets to its authored state the next time it loads. If a change should stay, such as a door that opens for good, draw it as a collision layer in the Room Editor and switch to it with tile_layer_set_active. The game remembers those. Switching to a different layer also lays the whole room down again, so a change you made with tile_set_class is lost then.
if (tile_class(x + 16, y) == TILE_SOLID) {
tile_set_class(x + 16, y, TILE_PASS);
}Checks the tile just ahead of the walker and, if it is a solid wall, knocks a passable hole through it - a one-line "digging" action. Nothing here changes what is drawn; a real dig would also place a broken-wall decoration or swap the walker's own facing sprite to show the effect.
On the Game Boy Color and the original Game Boy, a room keeps a list of the squares changed from the picture it was painted with. The list is as long as the number of different squares your code names with plain numbers, at least 32 (16 when only the class or flags change) and at most 255. A square put back to its painted tile gives its place back. A square your code works out while the game runs (from a variable or a loop) counts only toward the 32. A change that finds no free place is not drawn. On the Game Boy Color and the Game Boy, a game that changes more than 255 squares of a room sets Project Settings > Engine limits > Changed squares at once; up to the room's size is then kept.
Collision only - this does NOT change what is drawn there; a project that wants the room to visually change too still needs its own way to show that. tile_set_index (below) repaints exactly this one cell to a different tile from the same tileset - the direct pairing for a dig/destructible-terrain mechanic ("this cell no longer blocks" plus "this cell no longer looks solid" in the same two-line call site), and the one to reach for FIRST. An instance placed on top of the cell, or tile_anim_frame if the tileset already declares an animated group over that tile, remain the other two options - see tile_set_index’s own docs for how the three compare. A no-op if the current room has no collision tile layer, if (x, y) falls outside it, or if that layer’s own cell count is larger than this engine’s live-mutable budget (tile_flags() would still read the room’s original, unchanged data in that last case). Changes are NOT saved and do NOT persist across a room_change/room_restart or a save/load - the room’s tile layer resets to its authored state the next time it loads. A change that should stay (a door that opens for good) is a collision layer drawn in the Room Editor and switched on with tile_layer_set_active, which the game remembers.